﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AppFabricAdministrator
{
    public partial class SinglePermittedUser : UserControl
    {
        private string userAccount;
        public Action<SinglePermittedUser> callBack;
        string revokeUserCmdFormat = "Revoke-CacheAllowedClientAccount -Account \"{0}\"";
        public SinglePermittedUser(string userAccount, Action<SinglePermittedUser> callBack)
        {
            this.userAccount = userAccount;
            this.callBack = callBack;
            InitializeComponent();
            this.lblUser.Text = userAccount;
        }

        private void btnRemove_Click(object sender, EventArgs e)
        {
            var cmd = string.Format(revokeUserCmdFormat, this.userAccount);
            bool isSuccess;
            ScriptHelper.RunScript(cmd, "Removed user account.", null,out isSuccess);
            if (isSuccess)
                callBack(this);
        }
    }
}
